﻿CREATE TABLE [vehicle].[Vehicle] (
    [VehicleID]                 INT           IDENTITY (1, 1) NOT NULL,
    [VehicleTypeID]             INT           NULL,
    [VIN]                       VARCHAR (17)  NULL,
    [MakeID]                    INT           NULL,
    [ModelID]                   INT           NULL,
    [ColorID]                   INT           NULL,
    [ModelYear]                 INT           NULL,
    [TrimPackage]               VARCHAR (50)  NULL,
    [Weight]                    INT           NULL,
    [InsuranceProviderID]       INT           NULL,
    [InsurancePolicy]           VARCHAR (50)  NULL,
    [InsurancePolicyHolderName] VARCHAR (500) NULL,
    [InsuranceExpirationDate]   DATETIME      NULL,
    [ImageID]                   INT           NULL,
    [CreatedBy]                 VARCHAR (50)  NULL,
    [CreatedDate]               DATETIME      NULL,
    [UpdatedBy]                 VARCHAR (50)  NULL,
    [UpdatedDate]               DATETIME      NULL,
    [EndDate]                   DATETIME      NULL,
    CONSTRAINT [PK_Vehicle] PRIMARY KEY CLUSTERED ([VehicleID] ASC),
    CONSTRAINT [FK_Vehicle_Color] FOREIGN KEY ([ColorID]) REFERENCES [core].[Color] ([ColorID]),
    CONSTRAINT [FK_Vehicle_Image] FOREIGN KEY ([ImageID]) REFERENCES [core].[Image] ([ImageID]),
    CONSTRAINT [FK_Vehicle_InsuranceProvider] FOREIGN KEY ([InsuranceProviderID]) REFERENCES [core].[InsuranceProvider] ([InsuranceProviderID]),
    CONSTRAINT [FK_Vehicle_Make] FOREIGN KEY ([MakeID]) REFERENCES [core].[Make] ([MakeID]),
    CONSTRAINT [FK_Vehicle_Model] FOREIGN KEY ([ModelID]) REFERENCES [core].[Model] ([ModelID]),
    CONSTRAINT [FK_Vehicle_VehicleType] FOREIGN KEY ([VehicleTypeID]) REFERENCES [vehicle].[VehicleType] ([VehicleTypeID])
);

